package com.mhy.controller;

import com.mhy.common.id.SnowFlake;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName IdController
 * @Description
 * @Author mhy2011@163.com
 * @Date 2020-04-12 21:55:00
 * @Versioin 1.0
 */
@Slf4j
@RestController
@RequestMapping("/id")
public class IdController {

    private static final long DC_ID = 1L;
    private static final long WORKER_ID = 1L;

    private static SnowFlake SF = new SnowFlake(DC_ID, WORKER_ID);

    @RequestMapping("/next")
    public long next() {
        long id = SF.getId();
        log.info("generate id success. {}", id);
        return id;
    }
}
